#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int A[20];
ll d[20][5];

ll dp(int pos, int s, bool flg){
    if(pos == 0)
        return s == 3;
    if(flg && d[pos][s])
        return d[pos][s];
    int x = flg ? 9:A[pos];
    ll ans = 0;
    for (int i = 0; i <= x; ++i) {
        if(s==4) ans += dp(pos-1, i==0?4:0, flg||i<x);
        else if(s==0) ans += dp(pos-1, i==0? 1:0, flg||i<x);
        else if(s == 1) ans += dp(pos-1, i==0? 2:1, flg||i<x);
        else if(s == 2) ans += dp(pos-1, i==7? 3:2, flg||i<x);
        else ans += dp(pos-1, 3, flg||i<x);
    }
    if(flg) d[pos][s] = ans;
    return ans;
}

ll cal(ll x){
    int pos = 0;
    while (x){
        A[++pos] = x%10;
        x/=10;
    }
    return dp(pos, 4, false);
}

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int T; cin >> T;
    ll ans = 0;
    while (T--){
        ll l, r; cin >> l >> r;
        ans ^= cal(r) - cal(l-1);
    }
    cout << ans;
    return 0;
}